﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Oracle.DataAccess.Client;
using System.Data;

namespace Sweepids.Models.Object
{
    public class Category
    {
        //Columns
        public decimal CatId { get; set; }
        public string Name { get; set; }
        //Foreign keys
        //Oracle parameters
        public List<OracleParameter> OracleParameters
        {
            get
            {
                return new List<OracleParameter>
                    {
                        new OracleParameter(":CAT_ID", OracleDbType.Int32)
                            {
                                Value = CatId
                            },
                        new OracleParameter(":NAME", OracleDbType.Varchar2)
                            {
                                Value = Name ?? ""
                            }
                    };
            }
        }
        //Constructors
        public Category()
        {
            Name = "";
        }
        public Category(IDataRecord myReader)
        {
            CatId = myReader["CAT_ID"] == DBNull.Value ? 0 : (decimal) myReader["CAT_ID"];
            Name = myReader["NAME"] == DBNull.Value ? "" : (string) myReader["NAME"];
        }
    }
}